<?php
namespace Home\Model;
use Think\Model;
class MessageModel extends Model {
    public function addMessage($data){
        $this->add($data);
    }
    public function deleteMessageByUserId($user_id){
        $this->where("from_id='$user_id' or to_id='$user_id'")->delete();
    }
    public function deleteMessageById($id){
        $this->where("id='$id'")->delete();
    }

    public function getAllMessage(){
        return $this->select();
    }

    public function getMessageById($id){
        return $this->where("id='$id'")->select();
    }

    public function getMessageByFromIdANDToId($from_id,$to_id){
//        dump( $this->where("from_id='$from_id' and to_id ='$to_id' or from_id='$to_id' and to_id ='$from_id'")->order('create_time desc')->buildsql());die();
        return $this->where("from_id='$from_id' and to_id ='$to_id' or from_id='$to_id' and to_id ='$from_id'")->order('create_time desc')->select();
    }



}